﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using Kaiser.InversionOfControl.InstanceProviders;
using Kaiser.MvcBase.Models;
using Kaiser.MvcBase.Service;

namespace Kaiser.ManageClient
{
    public class TestUserService : IAuthenUserService
    {
        public UserModel FindUserModel(string name)
        {
          return new UserModel(){Account = "kaiser" ,ActiveTime = DateTime.Now,Name="kaiser"};
        }

        public bool Login(string account, string password, out MvcBase.Models.UserModel model)
        {
            model=new UserModel();
            return true;
        }

        public void Logout(string account)
        {
 
        }
    }

    public class UnityInstaller
    {
        public static IocContainer IocContainer = new IocContainer();
        public static void Install()
        {
            IocContainer.RegisterType<IAuthenUserService, TestUserService>();

            Assembly.GetExecutingAssembly()
                    .GetTypes()
                    .Where(type => type.Name.EndsWith("Controller"))
                    .ToList()
                    .ForEach(item => Kaiser.InversionOfControl.InstanceProviders.IocContainer.RegisterType(item));
             //Install();
            // UnityInstaller.Install();
            HttpContext.Current.Application.Add("IocContainer", IocContainer);
        }
    }
}